﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Pahan.McuFusion.UI.Controls
{
    public partial class DualPanelHexBox : UserControl
    {
        public DualPanelHexBox()
        {
            InitializeComponent();
            Panel1Options = new PanelOptions(tlpLeftTop, lbCaptionLeftTop, hbLeftTop);
            Panel2Options = new PanelOptions(tlpRightBottom, lbCaptionRightBottom, hbRightBottom);
        }

        #region Public Properties

        /// <summary>
        /// Gets the options of the left/top panel.
        /// </summary>
        [Description("Gets the options of the left/top panel.")]
        public PanelOptions Panel1Options
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets the options of the right/bottom panel.
        /// </summary>
        [Description("Gets the options of the right/bottom panel.")]
        public PanelOptions Panel2Options
        {
            get;
            private set;
        }

        [DefaultValue(Orientation.Horizontal)]
        public Orientation Orientation
        {
            get
            {
                return Invert(splitContainer.Orientation);
            }
            set
            {
                splitContainer.Orientation = Invert(value);
            }
        }

        [DefaultValue(PanelsVisibility.Both)]
        public PanelsVisibility PanelsVisible
        {
            get
            {
                if (splitContainer.Panel1Collapsed)
                {
                    return PanelsVisibility.RightBottom;
                }
                if (splitContainer.Panel2Collapsed)
                {
                    return PanelsVisibility.LeftTop;
                }
                return PanelsVisibility.Both;
            }
        }

        #endregion

        #region Private Methods

        private Orientation Invert(Orientation orientation)
        {
            return orientation == Orientation.Horizontal ?
                Orientation.Vertical :
                Orientation.Horizontal;
        }

        #endregion
    }
}
